<?php if(!defined('PHPOK_SET')){die('<h3>Error...</h3>');}?><?php $APP->tpl->p("header","","0");?>
<div class="notice"><div class="p">
	<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td><span class="lead">&nbsp;&raquo; <a href="<?php echo site_url('admin');?>">管理员列表</a> &raquo; 添加/编辑信息</span></td>
	</tr>
	</table>
</div></div>

<form method="post" action="<?php echo site_url('admin,setok');?>id=<?php echo $id;?>" onsubmit="return to_submit();">
<div class="table">
	<div class="left"><span class="red">*</span> 账号：</div>
	<input type="text" name="name" id="name" value="<?php echo $rs[name];?>">
</div>

<div class="table">
	<div class="left"><?php if(!$id){?><span class="red">*</span> <?php } ?>密码：</div>
	<input type="text" name="pass" id="pass" value="">
	<span class="clue_on"> <?php if($id){?>不修改密码请保留为空<?php }else{ ?>请填写密码<?php } ?></span>
</div>

<div class="table">
	<div class="left"><span class="red">*</span> 邮箱：</div>
	<input type="text" name="email" id="email" value="<?php echo $rs[email];?>">
</div>

<div class="table">
	<div class="left">权限：</div>
	<table cellpadding="0" cellspacing="0">
	<tr>
		<td><input type="radio" name="if_system" id="if_system_1" value="1"<?php if($rs[if_system]){?> checked<?php } ?> onclick="to_system(1)"></td>
		<td>&nbsp;系统管理员&nbsp; &nbsp;</td>
		<td><input type="radio" name="if_system" id="if_system_0" value="0"<?php if(!$rs[if_system]){?> checked<?php } ?> onclick="to_system(0)"></td>
		<td>&nbsp;常规管理员&nbsp; &nbsp;</td>
		<td class="clue_on"> 请慎用启用超级管理员权限！</td>
	</tr>
	</table>
</div>

<div id="no_system_admin"<?php if($rs[if_system]){?> style="display:none;"<?php } ?>>

	<div class="table tr_out" onmouseover="this.className='table tr_over'" onmouseout="this.className='table tr_out'">
		<div class="left">&nbsp;</div>
		<table cellpadding="0" cellspacing="0">
		<tr id="id_lang_list_0">
			<td valign="top"><a href="javascript:select_anti('id_lang_list_0');void(0);">【反选】</a></td>
			<td style="width:140px;height:23px;" valign="top">语言权限</td>
			<td valign="top"><table cellpadding="0" cellspacing="0"><tr>
					<?php $_i=0;$langlist=(is_array($langlist))?$langlist:array();foreach($langlist AS  $k=>$v){$_i++; ?>
					<td><input type="checkbox" name="mylangid[]" value="<?php echo $v[langid];?>"<?php if(in_array($v[langid],$lang_popedom )){?> checked<?php } ?>></td>
					<td>&nbsp;<?php echo $v[title];?> &nbsp;</td>
					<?php if($_i%4===0){echo '</tr><tr>';}?>
					<?php } ?>
				</tr></table></td>
		</tr>
		</table>
	</div>


<?php $_i=0;$mlist=(is_array($mlist))?$mlist:array();foreach($mlist AS  $key=>$value){$_i++; ?>
	<?php if($value[popedom]){?>
	<div class="table tr_out" onmouseover="this.className='table tr_over'" onmouseout="this.className='table tr_out'">
		<div class="left">&nbsp;</div>
		<table cellpadding="0" cellspacing="0">
		<tr id="id_popedom_list_<?php echo $value[id];?>">
			<td><a href="javascript:select_anti('id_popedom_list_<?php echo $value[id];?>');void(0);">【反选】</a></td>
			<td style="width:140px;height:23px;"><?php echo $value[title];?></td>
			<?php $p_id = explode(",",$value[popedom]);?>
			<?php $_i=0;$p_id=(is_array($p_id))?$p_id:array();foreach($p_id AS  $k=>$v){$_i++; ?>
			<td><input type="checkbox" name="popedom[]" value="<?php echo $value[id];?>:<?php echo $v;?>"<?php if(in_array($value[id].":".$v,$popedom)){?> checked<?php } ?>></td>
			<td>&nbsp;<?php echo $plist[$v];?> &nbsp;</td>
			<?php } ?>
		</tr>
		</table>
	</div>
	<?php } ?>
<?php } ?>
</div>
<div class="table">
	<div class="left">&nbsp;</div>
	<input type="submit" class="btn2" id="_phpok_submit" name="article_submit" value=" 提交 ">
</div>

</form>

<script type="text/javascript">
function to_system(v)
{
	if(v == 1)
	{
		getid("no_system_admin").style.display = "none";
	}
	else
	{
		getid("no_system_admin").style.display = "";
	}
	return true;
}
function to_submit()
{
	var name = getid("name").value;
	if(!name)
	{
		alert("会员名不允许为空");
		getid("name").focus();
		return false;
	}
	var email = getid("email").value;
	if(!email)
	{
		alert("邮箱不允许为空");
		getid("email").focus();
		return false;
	}
	<?php if(!$id){?>
	var pass = getid("pass").value;
	if(!pass)
	{
		alert("密码不允许为空");
		getid("pass").focus();
		return false;
	}
	<?php } ?>
	//通过Ajax检测会员账号和邮箱是否重复
	var url = "<?php echo site_url('admin,chk');?>id=<?php echo $id;?>&email="+EncodeUtf8(email)+"&name="+EncodeUtf8(name);
	var msg = get_ajax(url);
	if(!msg) msg = "error: 检测失败";
	if(msg != "ok")
	{
		alert(msg);
		return false;
	}
	getid("_phpok_submit").disabled = true;
}
</script>
<?php $APP->tpl->p("footer","","0");?>